/*
 * @(#)PACKAGE_NAME 2020/3/7/0007
 *
 * Copy Right@ 人人译视界
 */


import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;

/**
 * <pre>
 * @author tuwei
 *
 * @version 0.9
 *
 * 修改版本: 0.9
 * 修改日期: 2020/3/7/0007
 * 修改人 :  tuwei
 * 修改说明: 初步完成
 * 复审人 ：
 * </pre>
 */
public class BIORpcNetTransport {
	private String host;
	private int port;

	public BIORpcNetTransport(String host, int port) {
		this.host = host;
		this.port = port;
	}

	public Object send(RpcRequest request) {
		try (Socket socket = new Socket(host, port); ObjectOutputStream os = new ObjectOutputStream(socket.getOutputStream())) {
			os.writeObject(request);
			os.flush();
			ObjectInputStream is = new ObjectInputStream(socket.getInputStream());
			return is.readObject();
		}
		catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}
